package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.dto.EmpSocRelatedAddDTO;
import org.jsola.hr.dto.EmpSocRelatedUpdateDTO;
import org.jsola.hr.entity.EmpSocRelatedDO;
import org.jsola.hr.query.EmpSocRelatedQuery;
import org.jsola.hr.service.IEmpSocRelatedService;
import org.jsola.hr.vo.EmpSocRelatedVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 员工社保相关信息表
 *
 * @author zhr
 */
@Component
public class EmpSocRelatedTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpSocRelatedService empSocRelatedService;

    /**
     * 生成add测试数据
     * @return EmpSocRelatedAddDTO
     */
    public EmpSocRelatedAddDTO getEmpSocRelatedAddDTO(){
        EmpSocRelatedAddDTO empSocRelatedAddDTO = new EmpSocRelatedAddDTO();
        empSocRelatedAddDTO.setEmpId(getRandomValue("varchar",32));
        empSocRelatedAddDTO.setSchemeId(getRandomValue("varchar",32));
        empSocRelatedAddDTO.setSocState(SafeKit.getInteger(getRandomValue("tinyint",2)));
        empSocRelatedAddDTO.setPfState(SafeKit.getInteger(getRandomValue("tinyint",2)));
        empSocRelatedAddDTO.setMeState(SafeKit.getInteger(getRandomValue("tinyint",2)));
        empSocRelatedAddDTO.setSocAccount(getRandomValue("varchar",50));
        empSocRelatedAddDTO.setMeAccount(getRandomValue("varchar",50));
        empSocRelatedAddDTO.setPfAccount(getRandomValue("varchar",50));
        empSocRelatedAddDTO.setSocPlanIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setPfPlanIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setMePlanIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setSocIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setPfIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setMeIncreaseDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setSocPlanStopDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setPfPlanSealedDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setMePlanStopDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setSocStopDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setPfSealedDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setMeStopDate((Date)ClassKit.getObjectValue(getRandomValue("date",0),"java.util.Date"));
        empSocRelatedAddDTO.setCompanyId(getRandomValue("varchar",32));
        empSocRelatedAddDTO.setImportJson(getRandomValue("text",2147483647));
        return empSocRelatedAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpSocRelatedUpdateDTO
     */
    public EmpSocRelatedUpdateDTO getEmpSocRelatedUpdateDTO(EmpSocRelatedVO empSocRelatedVO){
        return empSocRelatedService.selectDOById(empSocRelatedVO.getId(), SITE_ID).to(EmpSocRelatedUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpSocRelatedQuery
     */
    public EmpSocRelatedQuery getEmpSocRelatedQuery() {
        EmpSocRelatedQuery empSocRelatedQuery = new EmpSocRelatedQuery();
        List<EmpSocRelatedDO> empSocRelatedDOList = empSocRelatedService.list(new EmpSocRelatedDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empSocRelatedDOList)) {
            EmpSocRelatedDO empSocRelatedDO = empSocRelatedDOList.get(0);
            empSocRelatedQuery = empSocRelatedDO.to(EmpSocRelatedQuery.class);
        }
        return empSocRelatedQuery;
    }

    /**
     * 保存示例
     * @return EmpSocRelatedVO
     */
    public EmpSocRelatedVO saveEmpSocRelatedExample(){
        EmpSocRelatedAddDTO addDTO = this.getEmpSocRelatedAddDTO();
        EmpSocRelatedVO empSocRelatedVO = empSocRelatedService.save(addDTO,buildTokenUser());
        return empSocRelatedVO;
    }


}

